package MicroSpring.builder;

import MicroSpring.beanFactory.impl.BeanDefinition;

/*
    BeanDefinition建造者
 */
public class BeanDefinitionBuilder {

    private BeanDefinition beanDefinition;

    public BeanDefinitionBuilder() {
        beanDefinition=new BeanDefinition();
    }


    public BeanDefinitionBuilder setIsAspect(boolean b){
        beanDefinition.setAspect(b);
        return this;
    }
    public BeanDefinitionBuilder setClass(Class clazz){
        beanDefinition.setClazz(clazz);
        return this;
    }
    public BeanDefinitionBuilder setScope(String scope){
        beanDefinition.setScope(scope);
        return this;
    }

    public BeanDefinitionBuilder setRepetable(boolean f){
        beanDefinition.setReplaceable(f);
        return this;
    }

    public synchronized BeanDefinition build(){
        BeanDefinition beanDefinition = this.beanDefinition;
        this.beanDefinition=new BeanDefinition();
        return beanDefinition;
    }

    public static void main(String[] args) {
        BeanDefinitionBuilder builder=new BeanDefinitionBuilder();
        BeanDefinition beanDefinition = builder
                .setClass(BeanDefinition.class)
                .setScope("single")
                .build();
        System.out.println(beanDefinition);

    }
}
